Structs

Roaring arrays are array-based key-value pairs having containers as values and 16-bit integer keys. A roaring bitmap might be implemented as such.

(For advanced users.) The roaring_statistics_t can be used to collect detailed statistics about the composition of a roaring bitmap.

What follows is code use to iterate through values in a roaring bitmap

Constants

Functions

Advance the iterator. If there is a new value, then it->has_value is true. The new value is in it->current_value. Values are traversed in increasing orders. For convenience, returns it->has_value.

Add value x Returns true if a new value was added, false if the value already existed.

Add value n_args from pointer vals, faster than repeatedly calling roaring_bitmap_add()

Add all values in range [min, max]

Computes the intersection between two bitmaps and returns new bitmap. The caller is responsible for memory management.

Computes the size of the intersection between two bitmaps.

Inplace version of roaring_bitmap_and(), modifies r1 r1 == r2 is allowed

Computes the difference (andnot) between two bitmaps and returns new bitmap. Caller is responsible for freeing the result.

Computes the size of the difference (andnot) between two bitmaps.

Inplace version of roaring_bitmap_andnot, modifies r1, r1 != r2.

Empties the bitmap. It will have no auxiliary allocations (so if the bitmap was initialized in client memory via roaring_bitmap_init(), then a call to roaring_bitmap_clear() would be enough to “free” it)

Check if value is present

Check whether a range of values from range_start (included) to range_end (excluded) is present

Copies a bitmap (this does memory allocation). The caller is responsible for memory management.

Dynamically allocates a new bitmap (initially empty). Returns NULL if the allocation fails. Capacity is a performance hint for how many “containers” the data will need. Client is responsible for calling roaring_bitmap_free().

Use with roaring_bitmap_serialize().

Return true if the two bitmaps contain the same elements.

Compute the negation of the bitmap in the interval [range_start, range_end). The number of negated values is range_end - range_start. Areas outside the range are passed through unchanged.

compute (in place) the negation of the roaring bitmap within a specified interval: [range_start, range_end). The number of negated values is range_end - range_start. Areas outside the range are passed through unchanged.

Frees the memory.

Add all the values between min (included) and max (excluded) that are at a distance k*step from min.

Serializes bitmap using frozen format. Buffer size must be at least roaring_bitmap_frozen_size_in_bytes().

Returns number of bytes required to serialize bitmap using frozen format.

Creates constant bitmap that is a view of a given buffer. Buffer data should have been written by roaring_bitmap_frozen_serialize() Its beginning must also be aligned by 32 bytes. Length must be equal exactly to roaring_bitmap_frozen_size_in_bytes(). In case of failure, NULL is returned.

Get the cardinality of the bitmap (number of elements).

Initialize a roaring bitmap structure in memory controlled by client. Capacity is a performance hint for how many “containers” the data will need. Can return false if auxiliary allocations fail when capacity greater than 0.

Check whether two bitmaps intersect.

Check whether a bitmap and a closed range intersect.

Returns true if the bitmap is empty (cardinality is zero).

Return true if all the elements of r1 are also in r2, and r2 is strictly greater than r1.

Return true if all the elements of r1 are also in r2.

Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto distance, or the Jaccard similarity coefficient)

(For expert users who seek high performance.)

(For expert users who seek high performance.)

Computes the symmetric difference between two bitmaps and returns new bitmap. The caller is responsible for memory management.

(For expert users who seek high performance.)

Returns the greatest value in the set, or 0 if the set is empty.

Returns the smallest value in the set, or UINT32_MAX if the set is empty.

Creates a new bitmap from a list of uint32_t integers

Creates a new bitmap from a pointer of uint32_t integers

Computes the union between two bitmaps and returns new bitmap. The caller is responsible for memory management.

Computes the size of the union between two bitmaps.

Inplace version of `roaring_bitmap_or(), modifies r1. TODO: decide whether r1 == r2 ok

Compute the union of ‘number’ bitmaps. Caller is responsible for freeing the result. See also roaring_bitmap_or_many_heap()

Compute the union of ‘number’ bitmaps using a heap. This can sometimes be faster than `roaring_bitmap_or_many() which uses a naive algorithm. Caller is responsible for freeing the result.

Copies a bitmap from src to dest. It is assumed that the pointer dest is to an already allocated bitmap. The content of the dest bitmap is freed/deleted.

Read bitmap from a serialized buffer. In case of failure, NULL is returned.

Read bitmap from a serialized buffer safely (reading up to maxbytes). In case of failure, NULL is returned.

Check how many bytes would be read (up to maxbytes) at this pointer if there is a bitmap, returns zero if there is no valid bitmap.

Write a bitmap to a char buffer. The output buffer should refer to at least roaring_bitmap_portable_size_in_bytes(r) bytes of allocated memory.

How many bytes are required to serialize this bitmap.

Print the content of the bitmap.

Describe the inner structure of the bitmap.

Returns the number of elements in the range [range_start, range_end).

Convert the bitmap to an array from offset by limit, output in ans.

roaring_bitmap_rank returns the number of integers that are smaller or equal to x. Thus if x is the first element, this function will return 1. If x is smaller than the smallest element, this function will return 0.

Remove value x Returns true if a new value was removed, false if the value was not existing.

Remove multiple values

Remove all values in range [min, max]

Remove run-length encoding even when it is more space efficient. Return whether a change was applied.

(For expert users who seek high performance.)

Convert array and bitmap containers to run containers when it is more efficient; also convert from run containers when more space efficient.

Selects the element at index ‘rank’ where the smallest element is at index 0. If the size of the roaring bitmap is strictly greater than rank, then this function returns true and sets element to the element of given rank. Otherwise, it returns false.

Write the bitmap to an output pointer, this output buffer should refer to at least roaring_bitmap_size_in_bytes(r) allocated bytes.

If needed, reallocate memory to shrink the memory usage. Returns the number of bytes saved.

How many bytes are required to serialize this bitmap (NOT compatible with Java and Go versions)

(For advanced users.)

Convert the bitmap to an array, output in ans,

Computes the symmetric difference (xor) between two bitmaps and returns new bitmap. The caller is responsible for memory management.

Computes the size of the symmetric difference (xor) between two bitmaps.

Inplace version of roaring_bitmap_xor, modifies r1, r1 != r2.

Compute the xor of ‘number’ bitmaps. Caller is responsible for freeing the result.

Creates a copy of an iterator. Caller must free it.

Create an iterator object that can be used to iterate through the values. Caller is responsible for calling roaring_free_iterator().

Free memory following roaring_create_iterator()

Initialize an iterator object that can be used to iterate through the values. If there is a value, then this iterator points to the first value and it->has_value is true. The value is in it->current_value.

Initialize an iterator object that can be used to iterate through the values. If there is a value, then this iterator points to the last value and it->has_value is true. The value is in it->current_value.

Iterate over the bitmap elements. The function iterator is called once for all the values with ptr (can be NULL) as the second parameter of each call.

Move the iterator to the first value >= val. If there is a such a value, then it->has_value is true. The new value is in it->current_value. For convenience, returns it->has_value.

Decrement the iterator. If there’s a new value, then it->has_value is true. The new value is in it->current_value. Values are traversed in decreasing order. For convenience, returns it->has_value.

Type Definitions

Roaring arrays are array-based key-value pairs having containers as values and 16-bit integer keys. A roaring bitmap might be implemented as such.

(For advanced users.) The roaring_statistics_t can be used to collect detailed statistics about the composition of a roaring bitmap.

What follows is code use to iterate through values in a roaring bitmap